;---------------------------------------
;shade-plot
;---------------------------------------

         *= $0b00

bitad    = $a8
sprad    = $aa
tymcz    = $ac
przesow  = $ad

         jmp start

;---------------------------------------

scradml  .byte $40,$41,$42,$43,$44,$45
         .byte $46,$47,$80,$81,$82,$83
         .byte $84,$85,$86,$87,$c0,$c1
         .byte $c2,$c3,$c4,$c5,$c6,$c7
         .byte $00,$01,$02,$03,$04,$05
         .byte $06,$07,$40,$41,$42,$43
         .byte $44,$45,$46,$47,$80,$81
         .byte $82,$83,$84,$85,$86,$87
         .byte $c0,$c1,$c2,$c3,$c4,$c5
         .byte $c6,$c7,$00,$01,$02,$03
         .byte $04,$05,$06,$07,$40,$41
         .byte $42,$43,$44,$45,$46,$47
         .byte $80,$81,$82,$83,$84,$85
         .byte $86,$87,$c0,$c1,$c2,$c3
         .byte $c4,$c5,$c6,$c7,$00,$01
         .byte $02,$03,$04,$05,$06,$07
         .byte $40,$41,$42,$43,$44,$45
         .byte $46,$47

scradst  .byte $40,$40,$40,$40
         .byte $40,$40,$40,$40,$41,$41
         .byte $41,$41,$41,$41,$41,$41
         .byte $42,$42,$42,$42,$42,$42
         .byte $42,$42,$44,$44,$44,$44
         .byte $44,$44,$44,$44,$45,$45
         .byte $45,$45,$45,$45,$45,$45
         .byte $46,$46,$46,$46,$46,$46
         .byte $46,$46,$47,$47,$47,$47
         .byte $47,$47,$47,$47,$49,$49
         .byte $49,$49,$49,$49,$49,$49
         .byte $4a,$4a,$4a,$4a,$4a,$4a
         .byte $4a,$4a,$4b,$4b,$4b,$4b
         .byte $4b,$4b,$4b,$4b,$4c,$4c
         .byte $4c,$4c,$4c,$4c,$4c,$4c
         .byte $4e,$4e,$4e,$4e,$4e,$4e
         .byte $4e,$4e,$4f,$4f,$4f,$4f
         .byte $4f,$4f,$4f,$4f

xadcbm   .byte $00,$00
         .byte $00,$00,$08,$08,$08,$08
         .byte $10,$10,$10,$10,$18,$18
         .byte $18,$18,$20,$20,$20,$20
         .byte $28,$28,$28,$28,$30,$30
         .byte $30,$30,$38,$38,$38,$38
         .byte $40,$40,$40,$40,$48,$48
         .byte $48,$48,$50,$50,$50,$50
         .byte $58,$58,$58,$58,$60,$60
         .byte $60,$60,$68,$68,$68,$68
         .byte $70,$70,$70,$70,$78,$78
         .byte $78,$78,$80,$80,$80,$80
         .byte $88,$88,$88,$88,$90,$90
         .byte $90,$90,$98,$98,$98,$98
         .byte $a0,$a0,$a0,$a0,$a8,$a8
         .byte $a8,$a8,$b0,$b0,$b0,$b0
         .byte $b8,$b8,$b8,$b8

;---------------------------------------

spradml  .byte $00,$03
         .byte $06,$09,$0c,$0f,$12,$15
         .byte $18,$1b,$1e,$21,$24,$27
         .byte $2a,$2d,$30,$33,$36,$39
         .byte $3c,$00,$03,$06,$09,$0c
         .byte $0f,$12,$15,$18,$1b,$1e
         .byte $21,$24,$27,$2a,$2d,$30
         .byte $33,$36,$39,$3c,$00,$03
         .byte $06,$09,$0c,$0f,$12,$15
         .byte $18,$1b,$1e,$21,$24,$27
         .byte $2a,$2d,$30,$33,$36,$39
         .byte $3c,$00,$03,$06,$09,$0c
         .byte $0f,$12,$15,$18,$1b,$1e
         .byte $21,$24,$27,$2a,$2d,$30
         .byte $33,$36,$39,$3c,$00,$03
         .byte $06,$09,$0c,$0f,$12,$15
         .byte $18,$1b,$1e,$21,$24,$27
         .byte $2a,$2d,$30,$33,$36,$39
         .byte $3c

spradst  .byte $52,$52,$52,$52,$52
         .byte $52,$52,$52,$52,$52,$52
         .byte $52,$52,$52,$52,$52,$52
         .byte $52,$52,$52,$52,$54,$54
         .byte $54,$54,$54,$54,$54,$54
         .byte $54,$54,$54,$54,$54,$54
         .byte $54,$54,$54,$54,$54,$54
         .byte $54,$56,$56,$56,$56,$56
         .byte $56,$56,$56,$56,$56,$56
         .byte $56,$56,$56,$56,$56,$56
         .byte $56,$56,$56,$56,$58,$58
         .byte $58,$58,$58,$58,$58,$58
         .byte $58,$58,$58,$58,$58,$58
         .byte $58,$58,$58,$58,$58,$58
         .byte $58,$5a,$5a,$5a,$5a,$5a
         .byte $5a,$5a,$5a,$5a,$5a,$5a
         .byte $5a,$5a,$5a,$5a,$5a,$5a
         .byte $5a,$5a,$5a,$5a

xadcspml .byte $00,$00
         .byte $00,$00,$01,$01,$01,$01
         .byte $02,$02,$02,$02,$40,$40
         .byte $40,$40,$41,$41,$41,$41
         .byte $42,$42,$42,$42,$80,$80
         .byte $80,$80,$81,$81,$81,$81
         .byte $82,$82,$82,$82,$c0,$c0
         .byte $c0,$c0,$c1,$c1,$c1,$c1
         .byte $c2,$c2,$c2,$c2,$00,$00
         .byte $00,$00,$01,$01,$01,$01
         .byte $02,$02,$02,$02,$40,$40
         .byte $40,$40,$41,$41,$41,$41
         .byte $42,$42,$42,$42,$80,$80
         .byte $80,$80,$81,$81,$81,$81
         .byte $82,$82,$82,$82,$c0,$c0
         .byte $c0,$c0,$c1,$c1,$c1,$c1
         .byte $c2,$c2,$c2,$c2

xadcspst .byte $00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$01,$01
         .byte $01,$01,$01,$01,$01,$01
         .byte $01,$01,$01,$01,$01,$01
         .byte $01,$01,$01,$01,$01,$01
         .byte $01,$01,$01,$01,$01,$01
         .byte $01,$01,$01,$01,$01,$01
         .byte $01,$01,$01,$01,$01,$01
         .byte $01,$01,$01,$01,$01,$01
         .byte $01,$01,$01,$01

;---------------------------------------

getand   .byte $c0,$30
         .byte $0c,$03,$c0,$30,$0c,$03
         .byte $c0,$30,$0c,$03,$c0,$30
         .byte $0c,$03,$c0,$30,$0c,$03
         .byte $c0,$30,$0c,$03,$c0,$30
         .byte $0c,$03,$c0,$30,$0c,$03
         .byte $c0,$30,$0c,$03,$c0,$30
         .byte $0c,$03,$c0,$30,$0c,$03
         .byte $c0,$30,$0c,$03,$c0,$30
         .byte $0c,$03,$c0,$30,$0c,$03
         .byte $c0,$30,$0c,$03,$c0,$30
         .byte $0c,$03,$c0,$30,$0c,$03
         .byte $c0,$30,$0c,$03,$c0,$30
         .byte $0c,$03,$c0,$30,$0c,$03
         .byte $c0,$30,$0c,$03,$c0,$30
         .byte $0c,$03,$c0,$30,$0c,$03
         .byte $c0,$30,$0c,$03

putand   .byte $3f,$cf
         .byte $f3,$fc,$3f,$cf,$f3,$fc
         .byte $3f,$cf,$f3,$fc,$3f,$cf
         .byte $f3,$fc,$3f,$cf,$f3,$fc
         .byte $3f,$cf,$f3,$fc,$3f,$cf
         .byte $f3,$fc,$3f,$cf,$f3,$fc
         .byte $3f,$cf,$f3,$fc,$3f,$cf
         .byte $f3,$fc,$3f,$cf,$f3,$fc
         .byte $3f,$cf,$f3,$fc,$3f,$cf
         .byte $f3,$fc,$3f,$cf,$f3,$fc
         .byte $3f,$cf,$f3,$fc,$3f,$cf
         .byte $f3,$fc,$3f,$cf,$f3,$fc
         .byte $3f,$cf,$f3,$fc,$3f,$cf
         .byte $f3,$fc,$3f,$cf,$f3,$fc
         .byte $3f,$cf,$f3,$fc,$3f,$cf
         .byte $f3,$fc,$3f,$cf,$f3,$fc
         .byte $3f,$cf,$f3,$fc

wstawtab .byte $00,$02,$03,$ff,$08,$00
         .byte $00,$00,$0c,$00,$00,$00
         .byte $ff,$00,$00,$00,$20,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$30,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $ff,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$80,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$c0,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $00,$00,$00,$00,$00,$00
         .byte $ff

tab1     .byte $40,$10,$04,$01

;---------------------------------------

start    lda scradml,y
         clc
         adc xadcbm,x
         sta bitad
         lda scradst,y
         adc przesow
         sta bitad+1

         lda spradml,y
         clc
         adc xadcspml,x
         sta sprad
         lda spradst,y
         adc xadcspst,x
         adc przesow
         sta sprad+1


         ldy #$00
         lda (bitad),y
         and getand,x
         beq specbmap
         tay
         lda wstawtab,y
         cmp #$ff
         beq sprite
         ldy #$00
         sta tymcz
         lda (bitad),y
         and putand,x
         ora tymcz
         sta (bitad),y
         rts
sprite   ldy #$00
         lda (sprad),y
         and getand,x
         beq specspr
         tay
         lda wstawtab,y
         cmp #$ff
         beq exit
         ldy #$00
         sta tymcz
         lda (sprad),y
         and putand,x
         ora tymcz
         sta (sprad),y
exit     rts
specbmap txa
         and #$03
         tax
         lda (bitad),y
         and putand,x
         ora tab1,x
         sta (bitad),y
         rts
specspr  txa
         and #$03
         tax
         lda (sprad),y
         and putand,x
         ora tab1,x
         sta (sprad),y
         rts

